package xyz.zeer.endangeredanimal;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class OtherAdapter extends RecyclerView.Adapter<OtherAdapter.ViewHolder> {

    private static List<OtherModel> yrs_otherModelList;
    private static Context yrs_context;

    public OtherAdapter(List<OtherModel> otherModelList, Context context) {
        this.yrs_otherModelList = otherModelList;
        this.yrs_context = context;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.yrs_other_content, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        String title = yrs_otherModelList.get(position).getTitle();
        String content = yrs_otherModelList.get(position).getContent();

        ViewHolder.setData( title, content);
    }

    @Override
    public int getItemCount() {
        return yrs_otherModelList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        private static TextView tvTitle;
        private static TextView tvContent;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvTitle = itemView.findViewById(R.id.tvTitle);
            tvContent = itemView.findViewById(R.id.tvContent);
        }

        public static void setData(String title, String content) {
            tvTitle.setText(title);
            tvContent.setText(content);
        }
    }
}
